package com.internship.javawebinternship.repository;

import ch.qos.logback.core.read.ListAppender;
import com.internship.javawebinternship.entity.Account;
import com.internship.javawebinternship.entity.StudentInfo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional;

import java.security.cert.X509Certificate;
import java.util.List;

public interface StudentInfoRepository extends JpaRepository<StudentInfo, String> {

    @Transactional(rollbackFor = Exception.class)
    @Modifying
    @Query(value = "select * from covid19.student_info where if(?1 !='',grade=?1,1=1)" +
            " and if(?2!='',classes=?2,1=1) and if(?3 !='',profession=?3,1=1) and if(?4 !='',college=?4,1=1) ", nativeQuery = true)
    public List<StudentInfo> findStudentGroup(String grade, String classes, String profession, String college);

    public StudentInfo findByStuno(String stuno);

}
